﻿using System;
using Microsoft.Win32;

namespace QLab.IO.Dialogs
{
  public class CustomOpenFileDialog
  {
    protected OpenFileDialog _dialog = new OpenFileDialog();
    protected string _fileName = String.Empty;

    public CustomOpenFileDialog()
    {
      Initialize();
    }

    protected virtual void Initialize()
    {
      _dialog.Multiselect = false;
    }

    public string FileName
    {
      get
      {
        return _fileName;
      }
    }

    public bool ShowDialog()
    {
      Nullable<bool> result = _dialog.ShowDialog();

      if (result.Equals(true))
      {
        _fileName = _dialog.FileName;
        return true;
      }
      else
      {
        _fileName = String.Empty;
        return false;
      }
    }

  }
}
